package com.xiyu.service.controller.admin.restaurant;
import com.xiyu.service.vo.restaurant.recipe.RecipePageQueryDetailOutput;
import com.xiyu.service.vo.restaurant.recipe.RecipePageQueryDetailInput;
import com.xiyu.service.vo.restaurant.recipe.RecipeListQueryComboOutput;
import com.xiyu.service.vo.restaurant.recipe.RecipeComboGetOutput;
import com.xiyu.service.vo.restaurant.recipe.RecipeComboUpdateInput;
import com.xiyu.service.vo.restaurant.recipe.RecipeComboCreateInput;
import com.xiyu.service.vo.restaurant.recipe.RecipeComboQueryInput;
import com.xiyu.service.vo.restaurant.recipe.RecipeComboQueryOutput;
import com.xiyu.service.vo.restaurant.recipe.RecipeGetOutput;
import com.xiyu.service.vo.restaurant.recipe.RecipeUpdateInput;
import com.xiyu.service.vo.restaurant.recipe.RecipeCreateInput;
import com.xiyu.service.vo.restaurant.recipe.RecipeQueryOutput;
import com.xiyu.service.vo.restaurant.recipe.RecipeQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.restaurant.RecipeService;

@Tag(name = "食谱管理")
@RestController
@RequestMapping("/restaurant/recipe")
@Validated
public class RecipeController {

    @Resource
    private RecipeService recipeService;

    @GetMapping("/query")
    @Operation(summary = "分页查询食谱")
    @PreAuthorize("@ss.hasPermission('restaurant:recipe:query')")
    public CommonResult<PageResult<RecipeQueryOutput>> query(@Valid RecipeQueryInput inputVO) {
        return success(recipeService.query(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新建食谱")
    @PreAuthorize("@ss.hasPermission('restaurant:recipe:create')")
    public CommonResult<Long> create(@Valid @RequestBody RecipeCreateInput inputVO) {
        return success(recipeService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新食谱")
    @PreAuthorize("@ss.hasPermission('restaurant:recipe:update')")
    public CommonResult<Boolean> update(@Valid @RequestBody RecipeUpdateInput inputVO) {
        return success(recipeService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除食谱")
    @PreAuthorize("@ss.hasPermission('restaurant:recipe:deleted')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(recipeService.deleted(id));
    }

    @GetMapping("/get")
    @Operation(summary = "获取单个食谱")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<RecipeGetOutput> get(@RequestParam("id") Long id) {
        return success(recipeService.get(id));
    }

    @GetMapping("/combo-query")
    @Operation(summary = "查询套餐")
    @PreAuthorize("@ss.hasPermission('restaurant:combo:query')")
    public CommonResult<PageResult<RecipeComboQueryOutput>> comboQuery(@Valid RecipeComboQueryInput inputVO) {
        return success(recipeService.comboQuery(inputVO));
    }

    @PostMapping("/combo-create")
    @Operation(summary = "创建套餐")
    @PreAuthorize("@ss.hasPermission('restaurant:combo:create')")
    public CommonResult<Long> comboCreate(@Valid @RequestBody RecipeComboCreateInput inputVO) {
        return success(recipeService.comboCreate(inputVO));
    }

    @PutMapping("/combo-update")
    @Operation(summary = "更新套餐")
    @PreAuthorize("@ss.hasPermission('restaurant:combo:update')")
    public CommonResult<Boolean> comboUpdate(@Valid @RequestBody RecipeComboUpdateInput inputVO) {
        return success(recipeService.comboUpdate(inputVO));
    }

    @DeleteMapping("/combo-deleted")
    @Operation(summary = "删除套餐")
    @PreAuthorize("@ss.hasPermission('restaurant:combo:deleted')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> comboDeleted(@RequestParam("id") Long id) {
        return success(recipeService.comboDeleted(id));
    }

    @GetMapping("/combo-get")
    @Operation(summary = "获取单个套餐")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<RecipeComboGetOutput> comboGet(@RequestParam("id") Long id) {
        return success(recipeService.comboGet(id));
    }

    @GetMapping("/list-query-combo")
    @Operation(summary = "查询餐饮套餐")
    public CommonResult<List<RecipeListQueryComboOutput>> listQueryCombo() {
        return success(recipeService.listQueryCombo());
    }

    @GetMapping("/page-query-detail")
    @Operation(summary = "分页查询食谱详情")
    public CommonResult<PageResult<RecipePageQueryDetailOutput>> pageQueryDetail(@Valid RecipePageQueryDetailInput inputVO) {
        return success(recipeService.pageQueryDetail(inputVO));
    }

}
